# -*- coding: UTF-8 -*-

numbers = [35, 33, 42, 10, 14, 19, 27, 44]

length = len(numbers)

# 获取增量
h = 1
while h < length / 3:
    h = 3 * h + 1

while h > 0:
    for i in range(h, length):
        tmp = numbers[i]
        j = i
        # 区间对比，交换位置
        while j > h - 1 and numbers[j - h] >= tmp:
            numbers[j] = numbers[j - h]
            j = j - h
        numbers[j] = tmp
    h = int((h - 1) / 3)

print(numbers)
